package f;

import f.f0.c;
import java.io.IOException;
import java.security.cert.Certificate;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;

/* compiled from: Handshake */
public final class p {
    public final e0 a;
    public final f b;
    public final List<Certificate> c;
    public final List<Certificate> d;

    public p(e0 e0Var, f fVar, List<Certificate> list, List<Certificate> list2) {
        this.a = e0Var;
        this.b = fVar;
        this.c = list;
        this.d = list2;
    }

    public static p a(SSLSession sSLSession) throws IOException {
        String cipherSuite = sSLSession.getCipherSuite();
        if (cipherSuite == null) {
            throw new IllegalStateException("cipherSuite == null");
        } else if ("SSL_NULL_WITH_NULL_NULL".equals(cipherSuite)) {
            throw new IOException("cipherSuite == SSL_NULL_WITH_NULL_NULL");
        } else {
            f a = f.a(cipherSuite);
            String protocol = sSLSession.getProtocol();
            if (protocol == null) {
                throw new IllegalStateException("tlsVersion == null");
            } else if ("NONE".equals(protocol)) {
                throw new IOException("tlsVersion == NONE");
            } else {
                Object[] peerCertificates;
                List q;
                List q2;
                e0 a2 = e0.a(protocol);
                try {
                    peerCertificates = sSLSession.getPeerCertificates();
                } catch (SSLPeerUnverifiedException unused) {
                    peerCertificates = null;
                }
                if (peerCertificates != null) {
                    q = c.q(peerCertificates);
                } else {
                    q = Collections.emptyList();
                }
                Certificate[] localCertificates = sSLSession.getLocalCertificates();
                if (localCertificates != null) {
                    q2 = c.q(localCertificates);
                } else {
                    q2 = Collections.emptyList();
                }
                return new p(a2, a, q, q2);
            }
        }
    }

    public boolean equals(@Nullable Object obj) {
        boolean z = false;
        if (!(obj instanceof p)) {
            return false;
        }
        p pVar = (p) obj;
        if (this.a.equals(pVar.a) && this.b.equals(pVar.b) && this.c.equals(pVar.c) && this.d.equals(pVar.d)) {
            z = true;
        }
        return z;
    }

    public int hashCode() {
        return this.d.hashCode() + ((this.c.hashCode() + ((this.b.hashCode() + ((this.a.hashCode() + 527) * 31)) * 31)) * 31);
    }
}
